package com.inkyi.assistant.app.component.rsyntax.action;

import org.fife.ui.rtextarea.RTextScrollPane;

import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * 显示行号
 */
public class ViewLineNumbersAction implements ItemListener {
    private final RTextScrollPane scrollPane;

    public ViewLineNumbersAction(RTextScrollPane scrollPane) {
        this.scrollPane = scrollPane;
    }

    @Override
    public void itemStateChanged(ItemEvent e) {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            scrollPane.setLineNumbersEnabled(true);
        } else if (e.getStateChange() == ItemEvent.DESELECTED) {
            scrollPane.setLineNumbersEnabled(false);
        }
    }
}
